package com.auz.datagenerator.heuristics.value;

import javax.swing.JPanel;

import com.auz.datagenerator.heuristics.value.gui.ValueHeuristicComponent;

/**
 * Value heuristic generating values following the trend adjusted
 * on the associated GUI component.
 * @author Aurelien Bonnel
 */
public class TrendValueHeuristic extends AbstractValueHeuristic<Double> {

	/**
	 * The default trend value ie. no trend
	 */
	public final double DEFAULT_TREND = 0.0;
	private double trend;
	
	/**
	 * Constructor
	 * @param _base - the base value
	 */
	public TrendValueHeuristic(double _base) {
		super(_base);
		trend = DEFAULT_TREND;
	}

	/**
	 * Returns the value associated with this heuristic
	 * @return the value
	 */
	public Double getValue() {
		// Returns the trend in percent
		return trend/100;
	}

	/**
	 * Returns the GUI component associated with this heuristic
	 * @return the GUI component associated with this heuristic
	 */
	public JPanel fetchGUIComponent() {
		component = new ValueHeuristicComponent(this, "Movement (arb): ");
		component.configureSlider(-40, 40, 0, 5, 10);
		component.pack();
		return component;
	}

	/**
	 * Sets the parameter value to the specified value
	 * @param _param - the new parameter value
	 */
	public void changeParameter(int _param) {
		trend = _param;
	}

	/**
	 * Returns the value associated with the representational function associated to this heuristic
	 * @return the value associated with the representational function associated to this heuristic
	 */
	public Double getRepresentationalValue(double _x) {
		return 0.0;
	}
}
